raar.compiler
Class StringTool

java.lang.Object
  extended byraar.compiler.StringTool

public class StringTool
extends java.lang.Object


Constructor Summary
StringTool()
           
 
Method Summary
static java.lang.String between(java.lang.String first, java.lang.String second, java.lang.String code)
          Returns the string in code between the two delimiters (first and second).
static java.lang.String betweenD(java.lang.String first, java.lang.String second, java.lang.String code)
          See between but delims must exist
static boolean contains(java.lang.String contains, java.lang.String s)
           
static java.lang.String headOfString(java.lang.String delim, java.lang.String s)
          Returns the head of a string when tokenizing it on delim.
static java.lang.String headOfStringD(java.lang.String delim, java.lang.String s)
          See headofstring but delim must exist
static boolean isDelimiter(char ch)
          Request whether the character is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).
static boolean isDelimiter(java.lang.String s)
          Request whether the FIRST character in the given string is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).
static java.lang.String[] readTokens(java.lang.String s, java.lang.String tokensafter, int ntokens)
          Read n tokens from s after the string tokensafter.
static java.lang.String removeSpaces(java.lang.String in)
           
static java.lang.String removeSpaces(java.lang.String in, java.lang.String spaces)
           
static java.lang.String replaceSpaces(java.lang.String in, java.lang.String spaces, java.lang.String by)
           
static java.lang.String revertString(java.lang.String s)
           
static java.lang.String stringBetweenMatching(java.lang.String openMark, java.lang.String closeMark, java.lang.String s)
          Returns the string between the two marks, which are considered to be paired.
static java.lang.String tailOfString(java.lang.String delim, java.lang.String s)
          Returns the tail of a string when tokenizing it on delim.
static java.lang.String tailOfStringD(java.lang.String delim, java.lang.String s)
          See tailofstring but delim must exist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTool

public StringTool()
Method Detail

headOfString

public static java.lang.String headOfString(java.lang.String delim,
                                            java.lang.String s)
Returns the head of a string when tokenizing it on delim. So, headOfString(":=", "Voorbeeld:=5") returns "Voorbeeld". If the delim doesn't exist in the string, the complete string is returned.

Parameters:
delim - The delimiter.
s - The string to get the head of.

headOfStringD

public static java.lang.String headOfStringD(java.lang.String delim,
                                             java.lang.String s)
                                      throws java.lang.StringIndexOutOfBoundsException
See headofstring but delim must exist

Throws:
java.lang.StringIndexOutOfBoundsException

tailOfString

public static java.lang.String tailOfString(java.lang.String delim,
                                            java.lang.String s)
Returns the tail of a string when tokenizing it on delim. So, tailOfString(":=", "Voorbeeld:=5") returns "5". If the delim doesn't exist in the string, the empty string is returned.

Parameters:
delim - The delimiter.
s - The string to get the tail of.

tailOfStringD

public static java.lang.String tailOfStringD(java.lang.String delim,
                                             java.lang.String s)
                                      throws java.lang.StringIndexOutOfBoundsException
See tailofstring but delim must exist

Throws:
java.lang.StringIndexOutOfBoundsException

between

public static java.lang.String between(java.lang.String first,
                                       java.lang.String second,
                                       java.lang.String code)
Returns the string in code between the two delimiters (first and second). Essentially takes the head of the string and takes the tail of that.


betweenD

public static java.lang.String betweenD(java.lang.String first,
                                        java.lang.String second,
                                        java.lang.String code)
                                 throws java.lang.StringIndexOutOfBoundsException
See between but delims must exist

Throws:
java.lang.StringIndexOutOfBoundsException

stringBetweenMatching

public static java.lang.String stringBetweenMatching(java.lang.String openMark,
                                                     java.lang.String closeMark,
                                                     java.lang.String s)
Returns the string between the two marks, which are considered to be paired. That is, the corresponding closing mark will be sought for for the first encountered opening mark. Example: [this[is[a]test]] with [ and ] as marks will return this[is[a]test].


removeSpaces

public static java.lang.String removeSpaces(java.lang.String in)

removeSpaces

public static java.lang.String removeSpaces(java.lang.String in,
                                            java.lang.String spaces)

replaceSpaces

public static java.lang.String replaceSpaces(java.lang.String in,
                                             java.lang.String spaces,
                                             java.lang.String by)

revertString

public static java.lang.String revertString(java.lang.String s)

contains

public static boolean contains(java.lang.String contains,
                               java.lang.String s)

isDelimiter

public static boolean isDelimiter(char ch)
Request whether the character is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).


isDelimiter

public static boolean isDelimiter(java.lang.String s)
Request whether the FIRST character in the given string is a delimiter (i.e. whitespace, newline, mathematical operator... anything that can split a word in two really).


readTokens

public static java.lang.String[] readTokens(java.lang.String s,
                                            java.lang.String tokensafter,
                                            int ntokens)
                                     throws java.lang.StringIndexOutOfBoundsException
Read n tokens from s after the string tokensafter. Except if there are less tokens.

Throws:
java.lang.StringIndexOutOfBoundsException